package com.lagou.java.utils;

import com.lagou.java.annotation.Autowired;
import com.lagou.java.annotation.Component;

import java.sql.SQLException;

@Component
public class TransactionManagerUtils {

    @Autowired
    private ConnectionUtils connectionUtils;

    //开启手动事物控制
    public void beginTransaction () throws SQLException {
        connectionUtils.getCurrentConnection().setAutoCommit(false);
    }

    //提交事物
    public void commintTransaction () throws SQLException {
        connectionUtils.getCurrentConnection().commit();

    }

    //回滚事物
    public void rollbackTransaction () throws SQLException {
        connectionUtils.getCurrentConnection().rollback();
    }
}
